home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Media Design Review 1999
/
Interactive Media Design Review 1999.iso
/
pc
/
allfiles
/
angry
/
intro.dir
/
00006_Script_gravity
< prev
next >
Wrap
Text File
|
1999-03-01
|
3KB
|
157 lines
property mySpr, mass, velocity, location
property timeScale, scale, systemOrigin
property frozen, activated
property animCount, myAnim
property flyMass
property pSoftSound, pHardSound
global stageWidth, stageHeight
on new me, thisSpr, thisAnim, thisSound
set mySpr = thisSpr
set myAnim = thisAnim
set timeScale = 50 -- seconds per update
set scale = 5 -- units per pixel
set pSoftSound = 0
set pHardSound = 0
if thisSound then
set pSoftSound = thisSound
set pHardSound = thisSound + 1
end if
set stageWidth = the stageRight - the stageLeft
set stageHeight = the stageBottom - the stageTop
set systemOrigin = [ #X:stageWidth/2, #Y:stageHeight/2 ]
-- puppetSprite mySpr, TRUE
set frozen = FALSE
set activated = FALSE
set mass = 65
set flyMass = 100
set velocity = [#X:0, #Y:0]
setloc me
return me
end new
on setloc me
set newX = (the locH of sprite(mySpr) - the X of systemOrigin) * scale
set newY = (the locV of sprite(mySpr) - the Y of systemOrigin) * scale
set location = [#X:newX, #Y:newY]
end setloc
on gravitate me
set mouseMass = mass / 2
set flyMouseMass = flyMass / 4
--------
if mySpr = 12 then
set N = flyGravity(mySpr, FlyMass, point(the mouseH, the mouseV),¼
flyMouseMass, 0, "attract") -- the mouse
else
set N = calcGravity(mySpr, mass) -- jean paul's
end if
push me, N
end gravitate
on push me, theForce
set acceleration = theForce / mass
set deltaVelocity = acceleration * timeScale
set velocity = velocity + deltaVelocity
-- bounce
set playSound = FALSE
if the bottom of sprite(mySpr) > stageHeight then
if the Y of velocity > 0 then
set the Y of velocity to - the Y of velocity
set playSound = TRUE
end if
end if
if the top of sprite(mySpr) < 0 then
if the Y of velocity < 0 then
set the Y of velocity to - the Y of velocity
set playSound = TRUE
end if
end if
if the left of sprite(mySpr) < 0 then
if the X of velocity < 0 then
set the X of velocity to - the X of velocity
set playSound = TRUE
end if
end if
if the right of sprite(mySpr) > stageWidth then
if the X of velocity > 0 then
set the X of velocity to - the X of velocity
set playSound = TRUE
end if
end if
if playSound AND pSoftSound AND random(2) = 2 then
set maxVeloc = max(abs(the X of velocity), abs(the Y of velocity))
if maxVeloc > 300 then puppetSound 2, pHardSound
else puppetSound 2, pSoftSound
end if
move me
end push
on move me
set location = location + velocity
set newLocH = the X of systemOrigin + (integer(the X of location) / scale)
set newLocV = the Y of systemOrigin + (integer(the Y of location) / scale)
set the locH of sprite(mySpr) = newLocH
set the locV of sprite(mySpr) = newLocV
end move
on animLoop me -- art animation
if animCount <> count(myAnim) then
set animCount = animCount + 1
if animCount >= count(myAnim) then
set animCount = count(myAnim)
end if
set the member of sprite(mySpr) = member getAt(myAnim, animCount)
else if animCount = count(myAnim) then
set animCount = 0
end if
end animLoop